//
//  HWFulijiemiamanViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/9/22.
//  Copyright © 2020 Chendaobin. All rights reserved.
//

#import "HWFulijiemiamanViewController.h"

#import "HWTradingViewController.h"
#import "HWDailyCheckController.h"  // 每日签到
#import "HWLoginController.h"
#import "HWOpenClothingViewController.h"
#import "HWTaskCenterViewController.h" // 任务中心界面
#import "HWPaiHangBangViewController.h" // 排行榜
#import "HWIntegralMallViewController.h" // 积分商城
#import "HWCustomerServiceCenterViewController.h" // 客服中心
#import "HWInviteFriendsViewController.h" //邀请好友
#import "HWLiBaoCenterViewController.h" // 礼包中心
#import <SafariServices/SafariServices.h>
#import "XMGWebViewController.h"
#import "HWPlatformActivityTableViewCell.h"
#import "HWfuliModel.h"
#import "HWWebViewGameViewController.h"
#import "HWIntegralMallshopViewController.h" // 新的积分商城
#import "HWGiftBagCenterzhongxingViewController.h" // 最新礼包中心
#import "HWxiaohaoSmallTransactionsViewController.h" //  最新小号交易
#import "HWyaoqinghaoyoujiemianViewController.h" // 最新的  邀请好友界面
#import "HWNewSignInViewController.h" //  最新每日签到



#import "HWTYouXiKaiFuViewController.h" // 新的游戏开服

#import "HWlingjuanzhongxingViewController.h"
#import "HWQuestionsViewController.h"
#import "HWTrumpetViewController.h"
#import "HWXingyaogpngjuTool.h"
#import "HWxiaohaoSmallTransactionsViewController.h"
@interface HWFulijiemiamanViewController ()<UITableViewDelegate,UITableViewDataSource>


@property(strong,nonatomic)UITableView *mainaTableVie;
@property(strong,nonatomic) UIView *headerView;
@property(strong,nonatomic) UIView *beijingView;
@property(strong,nonatomic) NSArray *fuliDataArr;
@property(strong,nonatomic) NSMutableArray *imageMuArr;
@property(strong,nonatomic) NSMutableArray *labelMuArr;
@property(strong,nonatomic) NSMutableArray *huodonMuArr;
@property(strong,nonatomic) UIView *zuixiamianview;
@property(strong,nonatomic) NSMutableArray *topdataMuArr;




@end

@implementation HWFulijiemiamanViewController



-(UITableView *)mainaTableVie {
    
    if  (_mainaTableVie == nil) {
        
        //   _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, -StatusBarHeight, kScreenW, kScreenH-TabBarHeight) style:UITableViewStylePlain];
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-TabBarHeight) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        _mainaTableVie.backgroundColor =  RGB(247, 247, 247);
        
        
        
    }
    return   _mainaTableVie ;
    
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    NSLog(@"1111111");
    
    
    //   [self chaxunUserCenter];
    //最新接口
    //    [self zuixingqingqiushuju];
    
    [self fulileimujiekou];
    
    
    [self huodongfuli];
    
    
    [self.navigationController setNavigationBarHidden:YES animated:NO];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    NSLog(@"22222222");
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    [self setUpUI];
    //   [self fulileimujiekou];
    
    // 福利活动
    //   [self huodongfuli];
    
    
}

// 福利活动
- (void)huodongfuli {
    
    
    NSString *userID = [HWLocallyStoredData getLoginUserID];
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",userID,tStr,@"fsd213ewdsadqwe2121213edsad"];
    NSString *signMD5 = [WMUtil md5HexDigest:sign];
    NSDictionary *parametes = @{
        
        @"ios" : @"1",
        @"member_id":[HWLocallyStoredData getCode],
        @"language":[HWjianzhiduiObject returnLanguageAcquisition],
        
        
        
    };
    
    
    
    //    [MBProgressHUD show:@"正在绑定邮箱"];
    
    [HWWebUtils do4GetWithParameters:parametes hiddenparameterStr:HW_huodong  progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        //   [MBProgressHUD hideHUD];
        
        
        if ([codeStr intValue] == 1) {
            
            
            self.huodonMuArr =   [HWfuliModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
            
            
            
            [self.mainaTableVie reloadData];
            
            
            
        } else {
            
            [MBProgressHUD  showSuccess:response[@"message"]];
            
        }
        NSLog(@"%@",response);
        
        
    } failure:^(NSString *error) {
        
        [MBProgressHUD  showError:@"查询失败"];
        
        
    }];
    
    
    
    
    
    
}


- (void)setUpUI  {
    
    [self addcontronView];
    
    [self addheadeView];
    
    
}


- (void)addcontronView {
    
    [self.view  addSubview:self.mainaTableVie];
    
    self.headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 112+NavBarHeight+20+ (20+4+17)*2+20+5)];
    self.headerView.backgroundColor = RGB(247, 247, 247);
    self.mainaTableVie.tableHeaderView = self.headerView;
    
    
    
}


- (void)addheadeView  {
    
    
    
    
    
    self.beijingView = [[UIView alloc]initWithFrame:CGRectMake(0, -StatusBarHeight, kScreenW, 112+NavBarHeight)];
    self.beijingView.backgroundColor = [UIColor bm_fulicolorGradientChangeWithSizeView: self.beijingView];
    [self.headerView addSubview: self.beijingView];
    
    
    
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(40,10, kScreenW-80, 20)];
    //     nameLabel.text = fanlilistArr[i];
    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont systemFontOfSize:18];
    nameLabel.textColor = RGB(255, 255, 255);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
    nameLabel.text = @"福利";
    nameLabel.text = [HWjianzhiduiObject keylocalization:@"福利"];
    
    [self.headerView addSubview:nameLabel];
    
    
    
    //  NSArray  *listArr = @[@"积分任务",@"积分商城",@"小号交易"];
    
    //     NSArray  *listArr = @[[HWjianzhiduiObject keylocalization:@"积分任务"],[HWjianzhiduiObject keylocalization:@"积分商城"],[HWjianzhiduiObject keylocalization:@"小号交易"]];
    //
    //      NSArray  *icoArr = @[@"jifenrenwu_ico",@"jifenshangcheng_ico",@"xiaohaojiaoyi_ico"];
    //
    
    
    NSArray  *listArr = @[[HWjianzhiduiObject keylocalization:@"每日答题"],[HWjianzhiduiObject keylocalization:@"小号回收"],[HWjianzhiduiObject keylocalization:@"积分任务"]];
    
    NSArray  *icoArr = @[@"meiridatiico", @"xiaohaohuishouico",@"jifenrenwu_ico"];
    
    CGFloat hengjianju = (kScreenW -3*80)/6;
    // CGFloat  shujianju = (166-100)/3;
    
    for (int i = 0 ; i < listArr.count; i++) {
        int shulian = (i*2+2) -1;
        
        
        //           UIButton *butt  = [UIButton setButtonWithFrame:CGRectMake(i*80+hengjianju*shulian, 112+NavBarHeight-20-72, 80, 72) Title:listArr[i] Image:icoArr[i] Font:13 Color:RGB(255, 255, 255) Target:self Selector:@selector(buttonTap:)];
        //         //  butt.backgroundColor = [UIColor redColor];
        //           butt.tag = i;
        //           [butt layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:1];
        //          // butt.backgroundColor = [UIColor redColor];
        //           [self.beijingView addSubview:butt];
        
        
        UIView *redview  = [[UIView alloc] initWithFrame:CGRectMake(i*80+hengjianju*shulian, 112+NavBarHeight-20-72, 80, 72)];
        redview.tag = i+300;
        redview.hidden = YES;
        
        [self.beijingView addSubview:redview];
        
        UIImageView *imview = [[UIImageView alloc]initWithFrame:CGRectMake(14, 0,  52,52)];
        //   imview.image = [UIImage imageNamed:paihangbangcoArr[i]];
        imview.userInteractionEnabled = YES;
        imview.tag = i+100;
        imview.image =  [UIImage imageNamed:icoArr[i]];
        [redview addSubview:imview];
        
        
        UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 52+5, 80, 15)];
        //  nameLabel.text = fanlilistArr[i];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.font = [UIFont systemFontOfSize:13];
        nameLabel.textColor = RGB(255, 255, 255);
        nameLabel.text= listArr[i];
        nameLabel.tag = i + 200;
        [redview addSubview:nameLabel];
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buttonTap:)];
        [redview addGestureRecognizer:tap1];
        
        
        
        
        
        
    }
    
    
    
    
    UIView *zuixiamianview = [[UIView alloc]initWithFrame:CGRectMake(0, self.beijingView.bottom, kScreenW,20+ (20+4+17)*2+20+20)];
    zuixiamianview.backgroundColor = [UIColor clearColor];
    self.zuixiamianview = zuixiamianview;
    [self.headerView addSubview:zuixiamianview];
    
    
    
    
    return;
    
    // 下面没有用上
    
    NSArray *fanlilistArr = @[@"申请返利",@"排行榜",@"礼包中心",@"联系客服",@"开服表",@" 邀请好友"];
    NSArray   *paihangbangcoArr = @[@"welfare_l1",@"welfare_l2",@"welfare_l3_libao",@"welfare_l4",@"welfare_l5",@"welfare_l6"];
    CGFloat hengjianjuLiin = (kScreenW-  (35*CFLScaleValue+25)*4)/8;
    self.imageMuArr = [[NSMutableArray alloc]init];
    self.labelMuArr = [[NSMutableArray alloc]init];
    for (int i = 0 ; i < 8; i++) {
        
        int row = i/4;
        int line = i%4;
        int shulian = (line*2+2) -1;
        
        UIView *redview = [[UIView alloc]initWithFrame:CGRectMake(hengjianjuLiin*shulian+line*(35*CFLScaleValue+25),20+ row*(20+4+17)+row*20, 35*CFLScaleValue+25, 20+4+17)];
        redview.backgroundColor = [UIColor whiteColor];
        [zuixiamianview addSubview:redview];
        
        
        
        UIImageView *imview = [[UIImageView alloc]initWithFrame:CGRectMake(((35*CFLScaleValue+25)-20)/2, 0,  20, 20)];
        //    imview.image = [UIImage imageNamed:paihangbangcoArr[i]];
        imview.userInteractionEnabled = YES;
        imview.tag = i;
        imview.backgroundColor = [UIColor  clearColor];
        
        // imview.hidden = YES;
        
        [redview addSubview:imview];
        
        [self.imageMuArr addObject:imview];
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imviewTaKaifu:)];
        [imview addGestureRecognizer:tap1];
        
        // UILabel
        UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 20+4, 35*CFLScaleValue+25, 17)];
        //     nameLabel.text = fanlilistArr[i];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.font = [UIFont systemFontOfSize:11];
        nameLabel.textColor = RGB(51, 51, 49);
        [redview addSubview:nameLabel];
        [self.labelMuArr addObject:nameLabel];
        
        
    }
    
    
    
    
    
    
    
    
    
}


- (void)imviewTaKaifu:(UITapGestureRecognizer *) sender {
    
    UIView *view =  sender.view;
    
    
    
    NSDictionary *dic = self.fuliDataArr[view.tag];
    NSString *urlStr = [NSString stringWithFormat:@"%@",dic[@"url"]];
    NSString *loginStr = [NSString stringWithFormat:@"%@",dic[@"login"]];
    NSString *type = [NSString stringWithFormat:@"%@",dic[@"type"]];
    if ([loginStr isEqualToString:@"1"]) {
        
        
        if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
            HWLoginController  *login = [[HWLoginController alloc]init];
            [self.navigationController pushViewController:login animated:YES];
            return;
            
        }
        
        
        
        
    }
    
    
    
    
    if (![urlStr isEqualToString:@""]) {
        
        //http://star.94php.com/?ct=choujiang&token=cC0PWoJSpHkFEPvAR2Lh_DaadCzWCXHcJ_blEBRIoqXyBaXAGuEOB3EuE1ALhA9i&t=1611035723&sign=1fa36d55ef6b6695a7654d99f8e33a1c
        
        
        //           if ([type integerValue] == 314) {
        //
        //
        //               HWlingjuanzhongxingViewController *CollectStamps = [[HWlingjuanzhongxingViewController alloc]init];
        //               [self.navigationController pushViewController:CollectStamps animated:YES];
        //
        //               return;
        //
        //
        //            }
        
        
        XMGWebViewController *webVc = [[XMGWebViewController alloc] init];
        webVc.url = [NSURL URLWithString:urlStr];
        [self.navigationController pushViewController:webVc animated:YES];
        
        return;
        
        
        
    }
    
    
    
    if ([type integerValue] == 310) {
        
        HWPaiHangBangViewController  *PaiHang = [[HWPaiHangBangViewController alloc]init];
        [self.navigationController pushViewController:PaiHang animated:YES];
        
        return;
        
        
    } else if ([type integerValue] == 311) {
        
        //        HWLiBaoCenterViewController  *liBao = [[HWLiBaoCenterViewController alloc]init];
        //             [self.navigationController pushViewController:liBao animated:YES];
        
        
        HWGiftBagCenterzhongxingViewController *libao = [[HWGiftBagCenterzhongxingViewController alloc]init];
        [self.navigationController pushViewController:libao animated:YES];
        
        
        
        
        
        
        return;
        
    }else if ([type integerValue] == 312) {
        
        //        HWOpenClothingViewController  *OpenClothing = [[HWOpenClothingViewController alloc]init];
        //              [self.navigationController pushViewController:OpenClothing animated:YES];
        //
        
        HWTYouXiKaiFuViewController *open = [[HWTYouXiKaiFuViewController alloc]init];
        [self.navigationController pushViewController:open animated:YES];
        
        
        return;
        
    }else if ([type integerValue] == 313) {
        
        
        //             HWInviteFriendsViewController *invitefriend = [[HWInviteFriendsViewController alloc]init];
        //             [self.navigationController pushViewController:invitefriend animated:YES];
        //
        //
        HWyaoqinghaoyoujiemianViewController *yaoqing = [[HWyaoqinghaoyoujiemianViewController alloc]init];
        [self.navigationController pushViewController:yaoqing animated:YES];
        
        
        
        
        
        return;
        
    }else if ([type integerValue] == 314) {
        
        //    name = "领券中心";
        
        HWlingjuanzhongxingViewController *CollectStamps = [[HWlingjuanzhongxingViewController alloc]init];
        [self.navigationController pushViewController:CollectStamps animated:YES];
        
        
        return;
        
    } else if([type intValue] == 321) {
        
        
        
        
        HWNewSignInViewController *newSign = [[HWNewSignInViewController alloc]init];
        [self.navigationController pushViewController:newSign animated:YES];
        
        
        
        //        HWDailyCheckController *dail = [[HWDailyCheckController alloc]init];
        //        [self.navigationController pushViewController:dail animated:YES];
        //
        
    } else if ([type integerValue] == 314) {
        
        
        HWlingjuanzhongxingViewController *CollectStamps = [[HWlingjuanzhongxingViewController alloc]init];
        [self.navigationController pushViewController:CollectStamps animated:YES];
        
        return;
        
        
    }else if ([type integerValue] == 328 ) {
        
        
        
        
        
        HWxiaohaoSmallTransactionsViewController *taskCenter = [[HWxiaohaoSmallTransactionsViewController  alloc]init];
        [self.navigationController pushViewController:taskCenter animated:YES];
        
        return;
        
        
        
        
        
        
    }else if ([type integerValue] == 329 ) {
        
        
        
        HWIntegralMallshopViewController *integralMall = [[HWIntegralMallshopViewController  alloc]init];
        [self.navigationController pushViewController:integralMall animated:YES];
        
        
        
        
    }
    
    
    
    return;
    
    
    
    
    
    
    
    //    if (view.tag == 0 ) {
    //
    ////        HWLoginController *login = [[HWLoginController alloc]init];
    ////        [self.navigationController pushViewController:login animated:YES];
    //
    //
    //
    //
    //
    //
    //    } else if (view.tag  == 1 ) {
    //
    //
    //        HWPaiHangBangViewController  *PaiHang = [[HWPaiHangBangViewController alloc]init];
    //        [self.navigationController pushViewController:PaiHang animated:YES];
    //
    //
    //
    //    }else if (view.tag  == 2 ) {
    //
    //
    //        HWLiBaoCenterViewController  *liBao = [[HWLiBaoCenterViewController alloc]init];
    //        [self.navigationController pushViewController:liBao animated:YES];
    //
    //
    //
    //    }else if (view.tag  == 3 ) {
    //
    ////        HWCustomerServiceCenterViewController *CustomerService = [[HWCustomerServiceCenterViewController alloc]init];
    ////        [self.navigationController pushViewController:CustomerService animated:YES];
    //
    //
    //
    //    }else if (view.tag  == 4 ) {
    //        HWOpenClothingViewController  *OpenClothing = [[HWOpenClothingViewController alloc]init];
    //        [self.navigationController pushViewController:OpenClothing animated:YES];
    //
    //
    //    }else if (view.tag  == 5 ) {
    //
    //
    //        HWInviteFriendsViewController *invitefriend = [[HWInviteFriendsViewController alloc]init];
    //        [self.navigationController pushViewController:invitefriend animated:YES];
    //
    //
    //
    //    } else {
    //
    //
    //    }
    
    
    
    
}



- (void)buttonTap:(UITapGestureRecognizer *)tap {
    
    UIView *sender =   tap.view;
    
    
    if (self.topdataMuArr != nil) {
        
        
        NSDictionary *dic =self.topdataMuArr[sender.tag-300];
        [HWXingyaogpngjuTool shujuDic:dic];
        
        
        
        return;
        
        
        
    }
    
    
    
    
    
    
    if (sender.tag ==  0+300) {
        
        
        if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
            
            HWLoginController  *login = [[HWLoginController alloc]init];
            [self.navigationController pushViewController:login animated:YES];
            return;
            
        }
        
        
        HWQuestionsViewController *question = [[HWQuestionsViewController alloc]init];
        [self.navigationController pushViewController:question animated:NO];
        
        
        
        //             HWTaskCenterViewController *taskCenter = [[HWTaskCenterViewController  alloc]init];
        //             [self.navigationController pushViewController:taskCenter animated:YES];
        //
        //
        
        
        
    } else if (sender.tag == 1+300) {
        
        //         HWIntegralMallViewController *integral = [[HWIntegralMallViewController alloc]init];
        //             [self.navigationController pushViewController:integral animated:YES];
        //
        
        //        HWIntegralMallshopViewController *integralMall = [[HWIntegralMallshopViewController  alloc]init];
        //        [self.navigationController pushViewController:integralMall animated:YES];
        //
        //
        
        if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
            
            HWLoginController  *login = [[HWLoginController alloc]init];
            [self.navigationController pushViewController:login animated:YES];
            return;
            
        }
        
        
        HWTrumpetViewController *trumpe = [[HWTrumpetViewController alloc]init];
        [self.navigationController pushViewController:trumpe animated:YES];
        
        
        
        
    } else if (sender.tag == 2+300) {
        
        
        
        
        
        
        //         HWTradingViewController *Trading = [[HWTradingViewController alloc]init];
        //        [self.navigationController pushViewController:Trading animated:YES];
        //
        
        //        HWxiaohaoSmallTransactionsViewController *xiahaojiao = [[HWxiaohaoSmallTransactionsViewController  alloc]init];
        //        [self.navigationController pushViewController:xiahaojiao animated:YES];
        //
        
        HWTaskCenterViewController *taskCenter = [[HWTaskCenterViewController  alloc]init];
        [self.navigationController pushViewController:taskCenter animated:YES];
        
        
        
        
    }
    
    
    
    
    
    
    
    
    //    if(sender.tag == 0) {
    //
    //        if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
    //                     HWLoginController  *login = [[HWLoginController alloc]init];
    //                       [self.navigationController pushViewController:login animated:YES];
    //                      return;
    //
    //        }
    //
    //
    //        HWDailyCheckController *Daily = [[HWDailyCheckController alloc]init];
    //        [self.navigationController pushViewController:Daily animated:YES];
    //
    //
    //    } else if(sender.tag == 1) {
    //
    ////        HWLoginController *logview = [[HWLoginController alloc]init];
    ////        [self.navigationController pushViewController:logview animated:YES];
    //
    //        HWIntegralMallViewController *integral = [[HWIntegralMallViewController alloc]init];
    //        [self.navigationController pushViewController:integral animated:YES];
    //
    //
    //
    //    } else {
    //
    //        if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
    //
    //            HWLoginController  *login = [[HWLoginController alloc]init];
    //            [self.navigationController pushViewController:login animated:YES];
    //                             return;
    //
    //        }
    //
    //
    //        HWTaskCenterViewController *taskCenter = [[HWTaskCenterViewController  alloc]init];
    //        [self.navigationController pushViewController:taskCenter animated:YES];
    //
    //
    //    }
    //
    
    DLog(@"每日签到");
    
}








// 福利类目
-(void)fulileimujiekou {
    
    
    
    NSString *userID = [HWLocallyStoredData getLoginUserID];
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",userID,tStr,@"fsd213ewdsadqwe2121213edsad"];
    NSString *signMD5 = [WMUtil md5HexDigest:sign];
    
    NSDictionary *parametes = @{
        
        @"ios" : @"1",
        @"uid" :userID,
        @"t" :tStr,
        @"member_id":[HWLocallyStoredData getCode],
        @"language":[HWjianzhiduiObject returnLanguageAcquisition],
        @"sign": signMD5
        
    };
    
    
    
    //    [MBProgressHUD show:@"正在绑定邮箱"];
    
    [HWWebUtils do4GetWithParameters:parametes  hiddenparameterStr:HW_fuli  progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        //   [MBProgressHUD hideHUD];
        
        
        if ([codeStr intValue] == 1) {
            
            self.fuliDataArr = response[@"data"];
            
            //福利刷新界面
            [self fulishuxingView];
            self.topdataMuArr =  nil;
            
            
            
            if ([response[@"topdata"] mutableCopy] == nil) {
                
                
                NSLog(@"%@",[response[@"topdata"] mutableCopy]);
                
                
            } else  {
                
                
                self.topdataMuArr  = [response[@"topdata"] mutableCopy];
                [self shuaxingtopdata];
                
                
            }
            
            
            
            
        } else {
            
            [MBProgressHUD  showSuccess:response[@"message"]];
            
        }
        NSLog(@"%@",response);
        
        
    } failure:^(NSString *error) {
        
        [MBProgressHUD  showError:@"查询失败"];
        
        
    }];
    
    
    
    
}



// 刷新 topdata
- (void)shuaxingtopdata  {
    
    
    
    if ( self.topdataMuArr == nil ) {
        
        
        for (int i = 0 ; i <  3; i++) {
            
            //   NSDictionary *dict =   self.topdataMuArr[i];
            
            
            UIView *view =   [self.beijingView viewWithTag:i+300];
            view.hidden = NO;
            //            UIImageView *imview =  [view viewWithTag:i+100];
            //            UILabel  *nameLabel = [view viewWithTag:i+200];
            
            //            NSURL *url = [NSURL URLWithString:dict[@"icon"]];
            //
            //
            //            [imview sd_setImageWithURL:url placeholderImage:nil];
            //            nameLabel.text = [NSString stringWithFormat:@"%@",dict[@"name"]];
            //
            
            
            
        }
        
    } else {
        
        
        
        for (int i = 0 ; i <  self.topdataMuArr.count; i++) {
            
            NSDictionary *dict =   self.topdataMuArr[i];
            
            
            UIView *view =   [self.beijingView  viewWithTag:i+300];
            view.hidden = NO;
            UIImageView *imview =  [view viewWithTag:i+100];
            UILabel  *nameLabel = [view viewWithTag:i+200];
            
            NSURL *url = [NSURL URLWithString:dict[@"icon"]];
            
            
            [imview sd_setImageWithURL:url placeholderImage:nil];
            nameLabel.text = [NSString stringWithFormat:@"%@",dict[@"name"]];
            
            if(i == 3) {
                
                
                return;
            }
            
            
        }
        
        
        
    }
    
    
    
    
    
    
    
}



//
- (void)fulishuxingView {
    
    
    
    
    
    
    
    
    
    
    CGFloat hengjianjuLiin = (kScreenW-  (35*CFLScaleValue+25)*4)/8;
    //   self.imageMuArr = [[NSMutableArray alloc]init];
    //  self.labelMuArr = [[NSMutableArray alloc]init];
    for (int i = 0 ; i < self.fuliDataArr.count; i++) {
        
        int row = i/4;
        int line = i%4;
        int shulian = (line*2+2) -1;
        
        UIView *redview = [[UIView alloc]initWithFrame:CGRectMake(hengjianjuLiin*shulian+line*(35*CFLScaleValue+25),20+ row*(20+4+17)+row*20, 35*CFLScaleValue+25, 20+4+17)];
        redview.backgroundColor = [UIColor whiteColor];
        redview.tag = i;
        [self.zuixiamianview addSubview:redview];
        
        
        NSDictionary *dic =  self.fuliDataArr[i];
        NSURL *url = [NSURL URLWithString: dic[@"icon"]];
        
        
        
        UIImageView *imview = [[UIImageView alloc]initWithFrame:CGRectMake(((35*CFLScaleValue+25)-20)/2, 0,  20, 20)];
        //    imview.image = [UIImage imageNamed:paihangbangcoArr[i]];
        imview.userInteractionEnabled = YES;
        imview.tag = i;
        imview.backgroundColor = [UIColor  clearColor];
        
        [imview sd_setImageWithURL:url placeholderImage:nil];
        
        // imview.hidden = YES;
        
        [redview addSubview:imview];
        
        [self.imageMuArr addObject:imview];
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imviewTaKaifu:)];
        [redview addGestureRecognizer:tap1];
        
        
        
        // UILabel
        UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 20+4, 35*CFLScaleValue+25, 17)];
        //     nameLabel.text = fanlilistArr[i];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.font = [UIFont systemFontOfSize:11];
        nameLabel.textColor = RGB(51, 51, 49);
        [redview addSubview:nameLabel];
        
        nameLabel.text = [NSString stringWithFormat:@"%@",dic[@"name"]];
        [self.labelMuArr addObject:nameLabel];
        
        
    }
    
    
    
    int row = (self.fuliDataArr.count - 1)/4;
    
    self.zuixiamianview.backgroundColor = [UIColor whiteColor];
    self.zuixiamianview.frame = CGRectMake(0, self.beijingView.bottom, kScreenW, 20+ (20+4+17)*row+20*row+20+20);
    
    self.headerView.frame = CGRectMake(0, 0, kScreenW, 112+NavBarHeight+20+ (20+4+17)*row+20*row+20 +20-StatusBarHeight+5);
    
    self.mainaTableVie.tableHeaderView =  self.headerView;
    
    
    
    //
    //    for (int i = 0; i < self.fuliDataArr.count; i++) {
    //
    //
    //        UIImageView *imageView = self.imageMuArr[i];
    //        UILabel *labe = self.labelMuArr[i];
    //
    //        NSDictionary *dic =  self.fuliDataArr[i];
    //        NSURL *url = [NSURL URLWithString: dic[@"icon"]];
    //        [imageView sd_setImageWithURL:url placeholderImage:nil];
    //        labe.text = [NSString stringWithFormat:@"%@",dic[@"name"]];
    //
    //
    //
    //
    //
    //    }
    
    
    
    
    
    
}









- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    
    return self.huodonMuArr.count;
    
    
    
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellId";
    
    
    HWPlatformActivityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"HWPlatformActivityTableViewCell" owner:nil options:nil].firstObject;
        
    }
    
    
    HWfuliModel *mode = self.huodonMuArr[indexPath.row];
    [cell.icoimageView sd_setImageWithURL:[NSURL URLWithString:mode.image] placeholderImage:nil];
    cell.nameLabel.text = mode.title;
    cell.riqiLabel.text = mode.time;
    cell.zhuantailabel.text = mode.type;
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    
    return  cell;
    
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    return  10+20+4+14+4+126+10;
    
}



- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 58)];
    view.backgroundColor = RGB(247, 247, 247);
    view.backgroundColor  = RGB(255, 255, 255);
    
    
    
    
    
    
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 25,5,18)];
    
    view1.backgroundColor = RGB(248, 119, 6);
    //    view1.layer.cornerRadius = 10;
    //    view1.layer.masksToBounds = YES;
    //
    [view addSubview:view1];
    
    
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(view1.right+6,20, 200, 28)];
    //     nameLabel.text = fanlilistArr[i];
    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.font = [UIFont systemFontOfSize:18];
    nameLabel.textColor = RGB(68, 68, 68);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
    nameLabel.text = @"平台活动";
    nameLabel.text = [HWjianzhiduiObject keylocalization:@"平台活动"];
    
    [view addSubview:nameLabel];
    
    
    
    
    
    return  view;
    
    
    
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    
    return 58;
    
    
    
    
}




- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    HWfuliModel *model = self.huodonMuArr[indexPath.row];
    
    
    
    HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
    webview.urlString = [NSString stringWithFormat:@"%@?ct=aznews&ac=info&id=%@&language=%@",[HWOCGlobalConst baseUrl],model.id,[HWjianzhiduiObject returnLanguageAcquisition]];
    
    webview.gname =model.title;
    webview.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:webview animated:YES];
    
    
    
    
}







- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    NSLog(@"变化 %f ---- %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
    
    if (scrollView.contentOffset.y  > 200 ) {
        
        //      self.daohaView.hidden = NO;
        //       self.biatiuLabe.textColor = RGB(68, 68, 68);
        
        //     [self.fanhuiBut setImage:[UIImage imageNamed:@"detailshei_back"] forState:UIControlStateNormal];
        
        [self.navigationController setNavigationBarHidden:NO];
        
        
    } else if (scrollView.contentOffset.y  < 60) {
        
        
        
        //     self.daohaView.hidden = YES;
        
        //   [self.fanhuiBut setImage:[UIImage imageNamed:@"details_back"] forState:UIControlStateNormal];
        //     self.biatiuLabe.textColor = RGB(68, 68, 68);
        [self.navigationController setNavigationBarHidden:YES];
        
    }
    
    
}







@end
